package com.gg.admin.user.contorller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.dao.AdminUserMapper;
import com.gg.entity.User;

import helpers.baseservlet.BaseServlet;

@WebServlet("/admin/AdminVerify2Servlet")
public class AdminVerify2Servlet extends BaseServlet {
	@Autowired
	private AdminUserMapper adminUserMapper;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String key=request.getParameter("key");
		User user =null;
		
		switch (key) {
		case "username":
			String username=request.getParameter("username");
			user=adminUserMapper.selectUserByUsername(username);
			if(user==null) {
				response.getWriter().print(true);
				
			}else {
				response.getWriter().print(false);
				
			}
			break;
		case "tel":
			String tel=request.getParameter("tel");
			user=adminUserMapper.selectUserByTel(tel);
			if(user==null) {
				response.getWriter().print(true);
				
			}else {
				response.getWriter().print(false);
				
			}
			break;
		case "email":
			String email=request.getParameter("email");
			user=adminUserMapper.selectUserByEmail(email);
			if(user==null) {
				response.getWriter().print(true);
				
			}else {
				response.getWriter().print(false);
				
			}
			break;
		default:
			break;
		}
	}

}
